<template>
  <div>
    <el-dialog
      title="上下架管理"
      :visible.sync="sellShow"
      width="30%"
    >
      <p>确认要{{ sellInfo.publishState ? '下架' : '上架' }}这件物品吗？</p>
      <span slot="footer">
        <el-button @click=" sellShow= false">取消</el-button>
        <el-button type="primary" @click="btnOK">确认</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import { sellTitle } from '@/api/choice'
export default {
  name: 'SellDialog',
  data() {
    return {
      sellShow: false,
      sellInfo: {}
    }
  },
  methods: {
    async btnOK() {
      try {
        if (this.sellInfo.publishState === 0) {
          this.sellInfo.publishState = 1
        } else {
          this.sellInfo.publishState = 0
        }
        console.log(this.sellInfo.publishState)
        await sellTitle(this.sellInfo)
        this.$message.success('操作成功')
      } catch (error) {
        console.log(error)
      }
      this.sellShow = false
      this.$emit('upload')
    }
  }

}
</script>

<style>

</style>
